/*
 * file:  expr.h (contains declarations of Expr)
 * Author: Jeremy Johnson 
 * Date: 1/29/06
 *
 * Description:
 */
#include <iostream>
#include <string>
#include <map>

using namespace std;


class Expr
{
public:
	Expr() {};
	virtual ~Expr() {};  
	virtual int eval(map<string,int> T) const = 0;  

// assume that T is not NULL and all variables occuring in T are in S
// pure virtual - i.e. do not provide implementation, but rather
// insist that all derived classes do.

private:
};

class Number : public Expr
{
public:
	Number(int value = 0);
	virtual int eval(map<string,int> T) const;
private:
	int value_;
};

class Ident : public Expr
{
public:
	Ident(string name = "");
	virtual int eval(map<string,int> T) const;
private:
	string name_;
};

class Times : public Expr
{
public:
	Times(Expr * op1 = NULL, Expr * op2 = NULL);
	virtual ~Times() {delete op1_; delete op2_;};
	virtual int eval(map<string,int> T) const;
private:
	Expr* op1_;
	Expr* op2_;
};

class Plus : public Expr
{
public:
	Plus(Expr* op1 = NULL, Expr* op2 = NULL);
	virtual ~Plus() {delete op1_; delete op2_;};
	virtual int eval(map<string,int> T) const;
private:
	Expr* op1_;
	Expr* op2_;
};

class Minus : public Expr
{
public:
	Minus(Expr* op1 = NULL, Expr* op2 = NULL);
	virtual ~Minus() {delete op1_; delete op2_;};
	virtual int eval(map<string,int> T) const;
private:
	Expr* op1_;
	Expr* op2_;
};
